<?php
class Default_Models_Mongo_LoginModel extends Shanty_Mongo_Document{
	protected static $_db = "call_link";
	protected static $_collection = "user";
	
	function login($arrParam){
	   	$auth = Thaind_Auth_Admin::getInstance();
	    $uname = trim($arrParam['username']);
	    $password = trim($arrParam['password']);
		if($uname == "" || $password == ""){
			return false;
		}else{
		    $paswd = md5(md5($password) . ' ' . md5($arrParam['salt']));
		    $result = $this->fetchOne(array('username'	=> $uname,'password'	=> $paswd));
    		if($result){
    			$data = (object)$result->export();
    			$auth->getStorage()->write($data);

	            // If "remember" was marked
	            if ($arrParam['remember']) {
	                Zend_Session::rememberMe();
	            }
                Zend_Session::start();
    			return true;
    		}else{
    			return false;
    		}
    	}
	}
}